/* 设置单选框选中效果 */
(function () {
    var curr = function (target) {
        var label = ["red", "green", "yellow", "blue"], obj = [], v;
        for (v in label) {
            obj[v] = target.find(".note-edit-" + label[v]);
            obj[v].find("input:checked").length && obj[v].addClass("note-edit-" + label[v] + "-curr");
            obj[v].click(function () {
                for (v in obj) {
                    var curr = "note-edit-" + label[v] + "-curr";
                    obj[v].find("input:checked").length ? obj[v].addClass(curr) : obj[v].removeClass(curr);
                }
            });
        }
    };
    curr($(".js-note-add"));
    curr($(".js-note-edit"));
})();

/* 添加按钮 */
$(".note-top-add").click(function () {

    // 当前点击的标签是哪个ID？
    //  get          获取
    //  Attribute    属性
    var id= this.getAttribute("data-id")
    console.log(id)

    $(".js-note-add").fadeIn(300);
});

/* 修改按钮 */
$(".note-list-edit").click(function () {

    var data_id = this.getAttribute('data-id')
    console.log(data_id)

    $('input[name="color"][value="red"]').prop('checked', true).parent().addClass("note-edit-red-curr")
    // $('input[name="color"][value="red"]').parent().addClass("note-edit-red-curr")

    $(".js-note-edit").fadeIn(300);

    $.get('selectOne.php', function (data) {
        console.log(data);
    });
});

/* 取消按钮 */
$(".note-edit-cancel").click(function () {
    $(this).parents(".note-layer").fadeOut(300);
});

/* 删除按钮 */
$(".note-list-delete").click(function () {
    return confirm('您确定要删除吗？');
});